package com.learn.spring.conditional;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author wangxing
 * @version 2020/6/12 13:21 Administrator
 */
public class TempConditional implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //判断容器中是否有dog的组件
        if (context.getBeanFactory().containsBean("dog")) {
            return true;
        }
        return false;
    }
}
